<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>驾驶证列表页面查询</title>
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/easyui_my.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx}/css/css.css" />
<script type="text/javascript" src="${ctx}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>
</head>
<body class="easyui-layout" options="border:false">
<div data-options="region:'north',height:95,border:false" style="padding-left:10px;padding-right: 10px;padding-top: 5px;">
  <div class="xinxichaxunkuangz1">
    <div class="dashujtiaojianxuanxiangkuan">
      <div class="dashujtiaojianxuanxiangkuan_lie">
          <div class="tiaojian_key">开始时间：</div>
          <div class="tiaojian_values">
            <ul class="tiaojian_values_limian">
              <li>
                <input id="startTime" type="text" name="startTime" class="easyui-datetimebox shurukuangkais"/>
              </li>
              <li><span class="buchongdbiaotdsw">结束时间：</span>
                <input id="endTime" type="text" name="endTime" class="easyui-datetimebox shurukuangkais"/>
              </li>
            </ul>
          </div>
        </div>
        <div class="dashujtiaojianxuanxiangkuan_lie">
          <div class="tiaojian_key">驾驶证号码：</div>
          <div class="tiaojian_values">
            <ul class="tiaojian_values_limian">
              <li><input id="sfzmhm" type="text" class="shurukuangkais" placeholder='请输入驾驶证号码'/></li>
            </ul>
          </div>
        </div>
      </div>
      <div class="chaxunchongzhianniu">
        <a href="javascript:queryDataGrid()" class="sousuocx">查询</a>
      </div>
    </div>
 </div>
<div data-options="region:'center',border:false" style="padding-left:10px;padding-right: 10px">
  <div class="easyui-layout xinxichaxunkuangz2" data-options="fit:true,border:false">
    <div class="tupianqiehuantop" data-options="region:'north',border:false" style="height: 37px">
      <span class="chaxunjieguosd">搜索结果</span>
    </div>
    <div id="tableDiv" data-options="region:'center',border:false" style="overflow-y: auto;">
      <table id="TableData" data-options="cls:'biaogeycangds',fit:true"></table>
    </div>
    <div data-options="region:'south',border:false" style="height:32px">
      <div class="easyui-panel">
        <div class="easyui-pagination" id="pp"></div>
      </div>
     </div>
  </div>
</div>

<script type="text/javascript">
    $(function(){
        //设置日期初始值
        $("#startTime").datetimebox("setValue",getDatex(8));
        $("#endTime").datetimebox("setValue",getDatex1(-1));
        initTable(1,20);
    });

    //数据表
    function initTable(pageNumber,pageSize){
        $("#TableData").datagrid({
            url:'${ctx}/yxxxgl/findJszxxPage.htm',
            fitColumns:true,
            border:false,
            striped:true,
            pagination: false,
            pageList: [5, 10, 15, 20, 30, 50], //分页记录数数组
            loadMsg:'数据加载中请稍后……',
            idField:'xh',
            queryParams:{
                pageSize:pageSize,
                page:pageNumber,
                sfzmhm:$("#sfzmhm").val(),
                startTime:$("#startTime").combobox('getValue'),
                endTime:$("#endTime").combobox('getValue')
            },
            columns:[[
                {field:'',checkbox:true,align:'center',fixed:true,split:true},
                {field:'dabh',title:'档案编号',width:'200',fixed:true,align:'center',split:true},
                {field:'xm',title:'姓名',width:'100',fixed:true,align:'center',split:true},
                {field:'sfzmhm',title:'身份证明号码',width:'200',fixed:true,align:'center',split:true},
                {field:'xb',title:'性别',width:'100',fixed:true,align:'center',split:true},
                {field:'fzjg',title:'发证机关',width:'80',fixed:true,align:'center',split:true},
                {field:'strCjsj',title:'经办时间',width:'200',fixed:true,align:'center',split:true},
                {field:'cjr',title:'经办人',width:'200',fixed:true,align:'center',split:true},
                {field:'cz',title:'操作',width:'110',align:'center',fixed:true,split:true,formatter:function(value,row,index){
                    return "<a class=\"chense2\" href=\"javascript:CheckInfo('"+row.xh+"','"+index+"')\" >详情</a>&nbsp;&nbsp;" +
                        "<a class=\"chense1\" href=\"javascript:delInfo('"+row.sfzmhm+"','"+row.xh+"')\" >删除</a>";
                }}
            ]],
            onDblClickRow: function (rowIndex, rowData) {
                CheckInfo(rowData.xh);
            },
            onLoadSuccess: function (data) {
                initPage(data.total);
            }
        });
    }

    function initPage(total){
        $('#pp').pagination({
            total:total,
            pageSize:'20',
            onSelectPage:function(pageNumber, pageSize){
                $("#TableData").datagrid("load",{
                    pageSize:pageSize,
                    page:pageNumber,
                    sfzmhm:$("#sfzmhm").val(),
                    startTime:$("#startTime").combobox('getValue'),
                    endTime:$("#endTime").combobox('getValue')
                });
            }
        });
    }
    function CheckInfo(xh){
        parent.addTab("驾驶证档案详情","${ctx}/yxxxgl/findJszByXh.htm?xh="+xh);
    }

    function delInfo(_sfzmhm,xh){
        debugger;
        if(confirm('确定删除该条信息吗?')){
            $.ajax({
                type:'POST',
                url:'${ctx}/audit/queryAuditInfo.htm',
                data:{
                    sfzmhm:_sfzmhm,
                    bussinessType:'2'
                },
                dataType:'json',
                success:function(data, textStatus, jqXHR){
                    if(null!=data && undefined!=data){
                        var flag=false;//当前用户还没有删除权限
                        $.each(data,function(i,info){
                            var permissionType=info.permissionType;//权限类型  03 删除权限 02 下载权限 01 打印权限
                            if(permissionType=='03'){
                                flag=true;
                            }
                        });
                        if(flag){
                            $.ajax({
                                type:'POST',
                                url:'${ctx}/yxxx/delVehicle.htm',
                                data:{
                                    xh:xh,
                                    bussinessType:'2'
                                },
                                success:function(data, textStatus, jqXHR) {
                                    debugger;
                                    if(data>0){
                                        alert('删除成功！');
                                        queryDataGrid();
                                    }else{
                                        alert('删除失败！');
                                    }
                                }
                            });
                        }else{
                            alert('目前还没有删除该信息的权限，请申请');
                            return false;
                        }
                    }
                }
            });
        }

    }

    //根据界面中的样件，过滤查询机动车基本信息列表
    function queryDataGrid(){
        var sfzmhm=$("#sfzmhm").val();//驾驶证档案信息
        var startTime = $("#startTime").combobox('getValue');
        var endTime = $("#endTime").combobox('getValue');
        $("#TableData").datagrid("load",{
            sfzmhm:sfzmhm,
            startTime:startTime,
            endTime:endTime
        });
    }
</script>
</body>
</html>
